package com.dearbinge.utils.httpClient;

import javax.servlet.http.HttpServletRequest;

import com.dearbinge.utils.MD5s;

/**
 * 校验url
 * @author aiche
 *
 */
public class UrlValidUtil {

	/**
	 * 校验url
	 * @return
	 */
	public static boolean urlValid(String sign ,String token ,HttpServletRequest request) {
		try {
			String strBackUrl = "http://" + request.getServerName() //服务器地址
                    + ":"
                    + request.getServerPort()           //端口号
                    + request.getContextPath()      //项目名称
                    + request.getServletPath() ;     //请求页面或其他地址
//                + "?" + (request.getQueryString()); //参数
			if(sign.equals(MD5s.execute(strBackUrl+token))){
				return true;
			}else{
				return false;
			}
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}

}
